<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../Vue.js"></script>
    <script src="./Axios.js"></script>
</head>

<body>
    <div class="div">
        <button @click="fetchs">点击</button>
        <ul>
            <template v-for="i in datelis">
                <li>{{i.name}}</li>
            </template>
        </ul>
    </div>
    <script>
        const obj = {
            data() {
                return {
                    datelis: []
                }
            },

            methods: {

                fetchs() {

                    // get请求
                    axios.get('http://localhost:3000/yy')
                    .then(res => {
                       // axios请求数据是要.data才能得到真正我们要的数据
                        console.log(res.data);
                        this.datelis=res.data
                    })
                    .catch(err => {  //请求数据时候失败了就走 .catch 成功走 .then
                        console.log(err + '没有数据');
                    })
                }
            }
        }
        Vue.createApp(obj).mount('.div')
    </script>
</body>

</html>